<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>10-合并</title>
    <script src="lib/react/react.development.js"></script>
    <script src="lib/react/react-dom.development.js"></script>
    <script src="lib/babel.min.js"></script>
  </head>
  <body>
    <div id="root"></div>
    <script type="text/babel">
      class HelloWorld extends React.Component {
        constructor(props) {
          super(props);
          this.state = {
            posts: [],
            comments: [],
          };
        }
        componentDidMount() {
          // 尚未测试
          fetchPosts().then((response) => {
            this.setState({
              posts: response.posts,
            });
          });

          fetchComments().then((response) => {
            this.setState({
              comments: response.comments,
            });
          });
        }

        render() {
          console.log("2. render...");
          return (
            <div>
              <h2>倒计时</h2>
              <span>{this.state.nowTime}</span>
            </div>
          );
        }
      }
      ReactDOM.render(<HelloWorld />, document.getElementById("root"));
    </script>
  </body>
</html>
